﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//New and needed
using IM.Domain.Repository;

namespace IM.Naive.Repository
{
    public class RepositoryLocatorEntityStore:RepositoryLocatorBase
    {

        protected Dictionary<Type, object> RepositoryMap = new Dictionary<Type, object>();

        public override IRepository<TRepository> GetRepository<TRepository>()
        {
            var type = typeof(TRepository);

            if (RepositoryMap.Keys.Contains(type))
            {
                return RepositoryMap[type] as IRepository<TRepository>;
            }

            var repository = new RepositoryEntityStore<TRepository>();
            RepositoryMap.Add(type, repository);
            return repository;
        }
    }
}
